<!-- 模块说明 -->
<script setup lang="ts">
import { log } from "console";
import { ref, onMounted, reactive, watch } from "vue";
import { IAdmin } from "../../api/index";
import { API } from "../../api/index";
import Table from "./table.vue";
const tableData = ref([]);
const val = ref<IAdmin>({
  current: 1,
  size: 2,
  username: "",
});
const total = ref<number>();
const getAdminList = async () => {
  let res = await API.admin(val.value);
  console.log(res.data.data.data, "获取管理员list");
  tableData.value = res.data.data.data;
  total.value = res.data.data.total;
};
const drawer = ref(false);
//关闭抽屉
const handleClose = (done: () => void) => {
  done();
};
const submit = () => {
  drawer.value != drawer.value;
  console.log(drawer.value, "呵呵");
};
onMounted(() => {
  getAdminList();
});
watch(
  val, //pagesize  pagenum
  () => {
    getAdminList();
  },
  {
    deep: true,
  }
);
</script>
<template>
  <div class="big">
    <el-button @click="submit">呵呵</el-button>
    <Table
      :list="tableData"
      :page="val"
      :onGetUserList="getAdminList"
      :total="total"
    >
    </Table>
    <el-drawer
      v-model="drawer"
      title="添加用户"
      direction="rtl"
      :before-close="handleClose"
    >
      <Form ref="form1"></Form>
      <template #footer>
        <div>
          <el-button>取消</el-button>
          <el-button type="primary" @click="submit">添加</el-button>
        </div>
      </template>
    </el-drawer>
  </div>
</template>

<style lang="scss" scoped>
.big {
  padding: 20px;
}
</style>
